<!DOCTYPE html>
<html>
<head lang="en">
	<meta charset='utf-8'/>
	<title>前后端交互-登录案例</title>
</head>
<body>

<span>用户名：</span><input type="text" class="username"/><br/>
<span>密码：</span><input type="text" class="password"/><br/>
<button>登录</button>

<script src='js/jquery-1.12.3.min.js'></script>
<script>
	
	$('button').click(function (){
		$.ajax({
			type:'post',
			url:'10loginDemo.php',
			dataType:'json',
			data:{
				myUname:$('.username').val(),
				myUpass:$('.password').val()
			},
			success:function (res){
				// console.log(res);
				if(res.infoCode == 0){
					//alert('登录成功');
					document.location.href = 'xxx新页面的url';
				}else if(res.infoCode == 1){
					alert('登录失败，账户名或密码错误');
				}else{
					alert('网络连接失败，请检查网络连接！');
				}
			}
		});
	});

</script>
</body>
</html>